<template>
  <div id="ranking-board">
    <div class="ranking-board-title">监控路段最新数据</div>
    <div class="table-container">
      <div class="table-header">
        <div class="col" v-for="(item, index) in headers" :key="index">
          {{ item }}
        </div>
      </div>
      <div class="rows">
        <div
          @click="choosePartner(item)"
          class="row"
          v-for="(item, index) in datas"
          :key="index"
        >
          <div class="col">{{ item.partnerName }}</div>
          <div class="col">{{ item.enterCameraIpNum || "--" }}</div>
          <div class="col">{{ item.outCameraIpNum || "--" }}</div>
          <div class="col">{{ item.diffNum || "--" }}</div>
          <div class="col">{{ item.dangerNum || "--" }}</div>
          <div class="col">{{ item.dangerPercent || "--" }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "RankingBoard",
  props: {
    datas: {
      type: [Array, String],
    },
  },
  data() {
    return {
      headers: [
        "监控路段",
        "入口数",
        "出口数",
        "路段车辆",
        "预警车辆数",
        "触发警报率",
      ],
      rankData: {},
    };
  },
  mounted() {
    this.rankData = JSON.parse(JSON.stringify(this.datas));
  },
  methods: {
    choosePartner(item) {
      this.$emit("choosePartner", item);
    },
  },
};
</script>

<style lang="less">
#ranking-board {
  width: 100%;
  box-shadow: 0 0 3px blue;
  display: flex;
  flex-direction: column;
  background-color: rgba(6, 30, 93, 0.5);
  border-top: 2px solid rgba(1, 153, 209, 0.5);
  box-sizing: border-box;
  padding: 0px 30px;
  height: 100%;
  overflow: hidden;
  .ranking-board-title {
    font-weight: bold;
    height: 50px;
    display: flex;
    align-items: center;
    font-size: 20px;
    padding-top: 20px;
  }

  .table-container {
    margin-top: 10px;
    border: 1px solid rgba(1, 153, 209, 0.5);
    .table-header {
      display: flex;
      padding: 20px;
      .col {
        flex: 1;
        text-align: center;
      }
    }
    .rows {
      .row {
        display: flex;
        border-bottom: 1px solid rgba(1, 153, 209, 0.5);
        cursor: pointer;
        .col {
          flex: 1;
          text-align: center;
          padding: 20px;
        }
      }
      .row:last-child {
        border-bottom: 0;
      }
    }
  }
}
</style>
